<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>{$current['title']}-{$Think.CONFIG.sitename}</title>

    <link href="__PUBLIC__/static/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="__PUBLIC__/static/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/static/css/animate.min.css" rel="stylesheet">
    <include file="Public/commoncss" />
    <!-- Sweet Alert -->
    <link href="__PUBLIC__/static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

</head>

<body class="gray-bg  top-navigation">
<div id="wrapper">
    <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom white-bg">
            <include file="Public/header" />
        </div>
        <div class="wrapper wrapper-content  animated fadeInRight">
            <div class="row">
                <div class="col-sm-3">
                    <div class="ibox float-e-margins">
                        <include file="Public/sidenav" />
                    </div>
                </div>
                <div class="col-sm-9">
                    <div class="ibox">

                        <div class="ibox-content">
                            <span class="text-muted small pull-right"><a href="{:U('add')}" class="btn btn-warning btn-xs">录入客户</a></span>
                            <h2>客户列表</h2>
                            <p>
                                所有客户必须证实有效录入
                            </p>
                            <form action="" method="get">
                                <div class="input-group">
                                    <input type="text" placeholder="查找客户"  name="keyword" value="{$_GET['keyword']}" class="input form-control" >
                                    <span class="input-group-btn">
                                                <button type="submit" class="btn btn btn-primary"> <i class="fa fa-search"></i> 搜索</button>
                                        </span>
                                </div>
                            </form>

                            <div class="clients-list">
                                <ul class="nav nav-tabs">
                                    <span class="pull-right small text-muted"> 您共录入 <strong>{$info.count}</strong>  个客户 最后录入时间：<i class="fa fa-clock-o"></i> {$info.time|beenTime}  </span>
                                    <li class="active"><a data-toggle="tab" href="#tab-1"><i class="fa fa-user"></i> 联系人</a>
                                    </li>

                                </ul>
                                <div class="tab-content">
                                    <div id="tab-1" class="tab-pane active">
                                        <div class="full-height-scroll">
                                            <div class="table-responsive">
                                                <table class="table table-striped table-hover">
                                                    <tbody>

                                                    <volist name="list" id="val" empty="没有找到匹配的记录">
                                                        <tr class="look" val="{$val.id}">
                                                            <td class="client-avatar">
                                                                <if condition="$val['head']">
                                                                    <img alt="image" src="{$val['head']}">
                                                                <else/>
                                                                    <img alt="image" src="__PUBLIC__/static/img/a1.jpg">
                                                                </if>
                                                            </td>
                                                            <td><a  href="{:U('view',array('id'=>$val['id']))}" class="client-link">{$val.name|SearchWords=$_GET['keyword']}</a>
                                                            </td>
                                                            <td><i class="fa fa-user-secret"> {$val.type|getMemberType}</td>
                                                            <td> {$val.sex|getCtmerSex}</td>
                                                            <td> {$val.hightech|SearchWords=$_GET['keyword']}</td>
                                                            <td ><i class="fa fa-envelope"> {$val.email} </i>
                                                            </td>
                                                            <td><i class="fa fa-mobile-phone"> {$val.phone|SearchWords=$_GET['keyword']}</td>
                                                            <td><i class="fa fa-phone"> {$val.tel|SearchWords=$_GET['keyword']}</td>
                                                            <td><i class="fa fa-qq"> {$val.qq|SearchWords=$_GET['keyword']}</td>
                                                            <td class="client-status">
                                                                <span class="stutas" val="{$val['stutas']}">{$val["stutas"]|getCtmerStu}</span>
                                                                <select class="stutasselect hide">
                                                                    <option value="0" class="yellow-bg" <if condition="$val['stutas'] eq 0">selected="selected"</if>>未验证</option>
                                                                    <option value="1" class="blue-bg" <if condition="$val['stutas'] eq 1">selected="selected"</if>>已验证</option>
                                                                    <option value="2" class="red-bg" <if condition="$val['stutas'] eq 2">selected="selected"</if>>已失效</option>
                                                                </select>
                                                            </td>
                                                            <td >
                                                                <a class="blue" href="{:U('edit',array('id'=>$val['id']))}" title="编辑"><i class="ace-icon fa fa-pencil-square-o bigger-100"></i>编辑</a>&nbsp;&nbsp;
                                                                <a class="red del" href="javascript:void(0);" val="{$val['id']}" title="删除"><i class="ace-icon fa fa-trash bigger-100"></i>删除</a>
                                                            </td>
                                                        </tr>
                                                    </volist>

                                                    </tbody>
                                                </table>
                                            </div>
                                            {$page}

                                        </div>
                                    </div>

                                </div>

                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>

        <include file="Public/footer" />
    </div>
</div>
<include file="Public/commonjs" />
<script src="__PUBLIC__/static/js/bootstrap.min.js?v=3.3.5"></script>
<script src="__PUBLIC__/static/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__PUBLIC__/static/js/content.min.js?v=1.0.0"></script>
<script src="__PUBLIC__/static/js/plugins/sweetalert/sweetalert.min.js"></script>
<script>
    $(function(){
        $(".full-height-scroll").slimScroll({height:"100%"})

        $(".stutas").click(function(){
            $(this).addClass('hide');
            $(this).parent().find(".stutasselect").removeClass('hide');
        })
        $(".stutasselect").on("change",function(){
            var ob = $(this);
            var stu=ob.val();
            var id = ob.parent().find('.stutas').attr('val');
            $.get("{:U('update')}?ajax=yes&id="+id+"&stu="+stu,function(data){
                var text = ob.find("option:selected").text();
                ob.parent().find(".stutas").removeClass('hide').html(text);
                ob.addClass('hide');
            });
        })

        //单个删除
        $('.del').click(function () {
            var id= $(this).attr("val");
            swal({
                title: "您确定删除这个客户信息吗",
                text: "删除后将无法恢复！",
                type: "info",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                cancelButtonText:"取消",
                confirmButtonText: "确定",
                closeOnConfirm: false
            }, function () {
                $.post("{:U('del')}",{id:id},function(data){
                    if(data.status !== 'y'){
                        swal('操作失败!', "参数错误原因可能是程序没有获取到参数！", "warning");
                    }else{
                        window.location.reload();
                    }
                });
            });
        });
    });
</script>

</body>

</html>